package com.wn.naturalbiorhythms.bean;

import java.io.Serializable;
import java.util.Calendar;

import com.wn.naturalbiorhythms.tool.NaturalBiorhythmsAlgorithm;
import com.wn.naturalbiorhythms.view.NaturalBiorhythmsView;

public class NaturalValue implements Serializable{
	

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private byte  physical;
	private byte  emotional;
	private byte intellictual;
	private byte intuitive;
	
	private Calendar calendar;
	
	private long dayLived;
	
	public NaturalValue(float  physical,float  emotional,float intellictual,float intuitive,Calendar cal,long birthdayMilliseconds){
		this.physical = (byte)Math.ceil(physical);
		this.emotional = (byte)Math.ceil(emotional);
		this.intellictual = (byte)Math.ceil(intellictual);
		this.intuitive = (byte)Math.ceil(intuitive);
		this.calendar = cal;
		
		dayLived = (this.calendar.getTimeInMillis()-birthdayMilliseconds)/NaturalBiorhythmsAlgorithm.ONE_DAY_MILLISECONDS;
	}

	public byte getPhysical() {
		return physical;
	}

	public byte getEmotional() {
		return emotional;
	}

	public byte getIntellictual() {
		return intellictual;
	}

	public byte getIntuitive() {
		return intuitive;
	}

	public long getDayLived() {
		return dayLived;
	}

	public Calendar getCalendar() {
		return calendar;
	}
	
	/**在周期里的某一天*/
	public byte getDayInCyclePhysical(){
		return (byte)(dayLived%NaturalBiorhythmsView.T_physical);
	}
	/**在周期里的某一天*/
	public byte getDayInCycleEmotional(){
		return (byte)(dayLived%NaturalBiorhythmsView.T_emotional);
	}
	/**在周期里的某一天*/
	public byte getDayInCycleIntellictual(){
		return (byte)(dayLived%NaturalBiorhythmsView.T_intellictual);
	}
	/**在周期里的某一天*/
	public byte getDayInCycleIntuitive(){
		return (byte)(dayLived%NaturalBiorhythmsView.T_intuitive);
	}
	
	public byte getTypeInCyclePhysical(){
		byte d = getDayInCyclePhysical();
		byte t = 0;
		if(d == NaturalBiorhythmsView.Day_Cycle){
			t = 0;
		}else if(d < NaturalBiorhythmsView.Day_Critical_physical){
			t = 1;
		}else if(d == NaturalBiorhythmsView.Day_Critical_physical){
			t = 2;
		}else{
			t = 3;
		}
		
		return t;
	}
	
	public byte getTypeInCycleEmotional(){
		byte d = getDayInCycleEmotional();
		byte t = 0;
		if(d == NaturalBiorhythmsView.Day_Cycle){
			t = 0;
		}else if(d < NaturalBiorhythmsView.Day_Critical_emotional){
			t = 1;
		}else if(d == NaturalBiorhythmsView.Day_Critical_emotional){
			t = 2;
		}else{
			t = 3;
		}
		
		return t;
	}
	
	public byte getTypeInCycleIntellictual(){
		byte d = getDayInCycleIntellictual();
		byte t = 0;
		if(d == NaturalBiorhythmsView.Day_Cycle){
			t = 0;
		}else if(d < NaturalBiorhythmsView.Day_Critical_intellictual){
			t = 1;
		}else if(d == NaturalBiorhythmsView.Day_Critical_intellictual){
			t = 2;
		}else{
			t = 3;
		}
		
		return t;
	}
	
	public byte getTypeInCycleIntuitive(){
		byte d = getDayInCycleIntuitive();
		byte t = 0;
		if(d == NaturalBiorhythmsView.Day_Cycle){
			t = 0;
		}else if(d < NaturalBiorhythmsView.Day_Critical_intuitive){
			t = 1;
		}else if(d == NaturalBiorhythmsView.Day_Critical_intuitive){
			t = 2;
		}else{
			t = 3;
		}
		
		return t;
	}


}
